//
//  YeeToastView.m
//  YWBaseFrameWork
//
//  Created by 余伟 on 2017/1/22.
//  Copyright © 2017年 NeiQuan. All rights reserved.
//

#import "YeeToastView.h"
@interface YeeToastView ()
{
   
    CAShapeLayer  *_shapeLayer;
    
}
@end
@implementation YeeToastView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame])
    {
        self.contentMode = UIViewContentModeCenter;
        self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin
								| UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
        [self addOwnViews];
    }
    
    return self;
}
-(void)addOwnViews
{
    //需要预估位置
    //_activityIndicatorView
   // CGFloat screenWidth=[UIScreen mainScreen].bounds.size.width;
    //CGFloat screenheight=[UIScreen mainScreen].bounds.size.height;
    _shapeLayer=[CAShapeLayer layer];
    _shapeLayer.path=[UIBezierPath bezierPathWithRoundedRect:CGRectMake((self.frame.size.width-135)*0.5,(self.frame.size.height-135-64)*0.5, 135, 135) cornerRadius:5.0].CGPath;
    _shapeLayer.fillColor=[UIColor colorWithWhite:0.6 alpha:0.5].CGColor;
    [self.layer addSublayer:_shapeLayer];
    
    //_activityIndicatorView
    _activityIndicatorView=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    [_activityIndicatorView setFrame:CGRectMake((self.frame.size.width-37)*0.5,(self.frame.size.height-135-64)*0.5+37/2.0 , 37, 37)];
    //[_activityIndicatorView startAnimating];
    [self addSubview:_activityIndicatorView];
    
    
    //_msgImageView
    _msgImageView=[[UIImageView alloc] initWithFrame:_activityIndicatorView.frame];
    _msgImageView.contentMode=UIViewContentModeScaleAspectFill;
    _msgImageView.clipsToBounds=YES;
    [self addSubview:_msgImageView];
    [_msgImageView setHidden:YES];
    
    _msglable=[[UILabel alloc] init];
    _msglable.text=@"正在加载中...";
    _msglable.font=[UIFont systemFontOfSize:12];
    _msglable.textColor=[UIColor whiteColor];
    _msglable.numberOfLines=0;
    _msglable.textAlignment=NSTextAlignmentCenter;
    [_msglable setFrame:CGRectMake((self.frame.size.width-125)*0.5, _activityIndicatorView.centerY+21, 120, 45)];
    [self addSubview:_msglable];
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
}

@end
